﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.User;
using PowerCreator.LMS.Web.Task;
using PowerCreator.LMS.Task.Entity;
using PowerCreator.LMS.ViewQuery;
using PowerCreator.LMS.Common.Utils;

public partial class sysadmin_TaskManager_EditTaskClass : System.Web.UI.Page
{
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    TaskClassManag objTaskClassManag = new TaskClassManag();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Params["TID"] != null && Request.Params["TID"].Trim() != "")
            {
                ViewState["TaskID"] = Request.Params["TID"].ToString();
            }
            if (Request.Params["CID"] != null && Request.Params["CID"].Trim() != "")
            {
                int id = int.Parse(Request.Params["CID"].ToString());
                ViewState["TaskCsID"] = id;
                PageLoad(id);

            }
            
        }
    }
    public void PageLoad(int taskCsID)
    {
        TaskClass objTaskClass=objTaskClassManag.Load(taskCsID);
        txtTaskCsName.Text= objTaskClass.TaskCsName;
        txtTaskCsStartTime.Text = objTaskClass.TaskCsStartTime.ToString();
        txtTaskCsEndTime.Text = objTaskClass.TaskCsEndTime.ToString();
        
        //DataTable dtTaskClassRoom = objTaskClassRoomManag.Query("");
        //dpdlsTaskClassRoomt.DataSource = dtTaskClassRoom;
        //dpdlsTaskClassRoomt.DataTextField = "TaskCrName";
        //dpdlsTaskClassRoomt.DataValueField = "TaskCrID";
        //dpdlsTaskClassRoomt.DataBind();

        //DataTable dtTaskEvaluate = objEvaluateManag.Query("");
        //dpdlstTaskEvaluateName.DataSource = dtTaskEvaluate;
        //dpdlstTaskEvaluateName.DataTextField = "EvateName";
        //dpdlstTaskEvaluateName.DataValueField = "EvateID";
        //dpdlstTaskEvaluateName.DataBind();

        //DataTable dtTaskTeacher = objUser.QueryTeacher("", int.MaxValue, int.MaxValue);
        //dpdlstTaskTeacherID.DataSource = dtTaskTeacher;
        //dpdlstTaskTeacherID.DataTextField = "TeacherName";
        //dpdlstTaskTeacherID.DataValueField = "FKTeacherUserId";
        //dpdlstTaskTeacherID.DataBind();

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strErr = "";
        if (this.txtTaskCsName.Text == "")
        {
            strErr += "小组名称不能为空！\\n";
        }
        if (!TimeUtils.IsDateTime(txtTaskCsStartTime.Text))
        {
            strErr += "开始时间不是时间格式！\\n";
        }
        if (!TimeUtils.IsDateTime(txtTaskCsEndTime.Text))
        {
            strErr += "结束时间不是时间格式！\\n";
        }
        if (strErr != "")
        {
            Script.Alert(this, "msg", strErr);
            return;
        }

        TaskClass model = objTaskClassManag.Load(int.Parse(ViewState["TaskCsID"].ToString()));

        //int FKTaskID = int.Parse(ViewState["TaskID"].ToString());
        string TaskCsName = this.txtTaskCsName.Text;
        //int TaskCsTrainingDays = 0;
        DateTime TaskCsStartTime = DateTime.Parse(this.txtTaskCsStartTime.Text);
        DateTime TaskCsEndTime = DateTime.Parse(this.txtTaskCsEndTime.Text);
        //int TaskCsTimeType = 1;
        //int TaskCsUserCount = 0;
        //int TaskCsAuditState = 0;
        //int TaskCsUserType = 0;
        //int FKTaskCsTeacherID = 10000;
        //int FKTaskCsClassRoomID = 0;
        //DateTime TaskCsCreateTime = DateTime.Now;
        //int FKTaskCsCreateID = 10000; 

        //TaskClass model = new TaskClass();
        //model.FKTaskID = FKTaskID;
        model.TaskCsName = TaskCsName;
        //model.TaskCsTrainingDays = TaskCsTrainingDays;
        model.TaskCsStartTime = TaskCsStartTime;
        model.TaskCsEndTime = TaskCsEndTime;
        //model.TaskCsTimeType = TaskCsTimeType;
        //model.TaskCsUserCount = TaskCsUserCount;
        //model.TaskCsAuditState = TaskCsAuditState;
        //model.TaskCsUserType = TaskCsUserType;
        //model.FKTaskCsTeacherID = FKTaskCsTeacherID;
        //model.FKTaskCsClassRoomID = FKTaskCsClassRoomID;
        //model.TaskCsCreateTime = TaskCsCreateTime;
        //model.FKTaskCsCreateID = FKTaskCsCreateID;
        objTaskClassManag.Update(model);
        Script.RedirectURL("TaskClassManager.aspx?id=" + ViewState["TaskID"].ToString());
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        Script.RedirectURL("TaskClassManager.aspx?id=" + ViewState["TaskID"].ToString());
    }

}

